package com.prabhakar.taxiclubapp;

import android.app.TabActivity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TabHost;
import android.widget.Toast;
import android.widget.TabHost.TabSpec;

public class TaxiClubActivity extends TabActivity {

	private static final String Package_Path ="com.prabhakar.taxiclubapp";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_taxi);

		TabHost tabHost = getTabHost();

		// Tab for Point-to-Point
		TabSpec p2pspec = tabHost.newTabSpec("Point-to-Point");
		// setting Title and Icon for the Tab
		p2pspec.setIndicator("Point-to-Point", getResources().getDrawable(R.drawable.icon_p2ptaxi_tab));
		Intent p2pTaxiIntent = new Intent(this, P2PActivity.class);
		p2pspec.setContent(p2pTaxiIntent);

		// Tab for Airport
		TabSpec airportspec = tabHost.newTabSpec("Airport/Railway Transfer");
		// setting Title and Icon for the Tab
		airportspec.setIndicator("Airport /Railway Transfer", getResources().getDrawable(R.drawable.icon_airporttaxi_tab));
		Intent airportTaxiIntent = new Intent(this, AirportPackageActivity.class);
		airportspec.setContent(airportTaxiIntent);


		// Tab for Hourly-Package
		TabSpec hourlyspec = tabHost.newTabSpec("hourly packages");
		// setting Title and Icon for the Tab
		hourlyspec.setIndicator("hourly packages", getResources().getDrawable(R.drawable.icon_hourlytaxi_tab));
		Intent hourlyTaxiIntent = new Intent(this, HourlyPackageActivity.class);
		hourlyspec.setContent(hourlyTaxiIntent);
		

		// Tab for Outstation
		TabSpec outstationspec = tabHost.newTabSpec("outstation packages");
		// setting Title and Icon for the Tab
		outstationspec.setIndicator("outstation packages", getResources().getDrawable(R.drawable.icon_outstationtaxi_tab));
		Intent outstationTaxiIntent = new Intent(this, OutstationPackageActivity.class);
		outstationspec.setContent(outstationTaxiIntent);

		// Adding all TabSpec to TabHost
		tabHost.addTab(p2pspec); // Adding p2p tab
		tabHost.addTab(airportspec); // Adding airport tab
		tabHost.addTab(hourlyspec); // Adding hourly tab
		tabHost.addTab(outstationspec); // Adding outstation tab

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.taxi_club, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId()) {
		case R.id.fare_summary:
			showFareSummary();
			Toast.makeText(this, "Rs/Km clicked...!!!", Toast.LENGTH_LONG).show();
			return true;

		default:
			return super.onOptionsItemSelected(item);
		}
		
	}
	
	private void showFareSummary() {
		// TODO Auto-generated method stub
		Intent startTaxiBookingIntent = new Intent();
		startTaxiBookingIntent.setComponent(new ComponentName(Package_Path, "com.prabhakar.taxiclubapp.FareSummary"));
		TaxiClubActivity.this.startActivity(startTaxiBookingIntent);
	}
	
	
}
